package org.uim.cricket.updater;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class UpdateFetchBeans {

	private String beanFile = null;
	protected ApplicationContext context = null;
	
	public UpdateFetchBeans(String theBeanFile) {
		beanFile = theBeanFile;
	}
	
	public void loadBeans() {
		context = new FileSystemXmlApplicationContext(this.beanFile);
	}
	
	public Object fetchBean(String key) {
		if (context == null) return null;
		return context.getBean(key);
	}
	
	public void setBeanFile(String beanFile) {
		this.beanFile = beanFile;
	}
	
	public String getBeanFile() {
		return beanFile;
	}
	
	public ApplicationContext getContext() {
		return context;
	}
	
	public Updatable getUpdateBean(String fbeanKey) {
		return (Updatable) context.getBean(fbeanKey);
	}

}
